Abnum

Abnum is an alphabetic numerals python package/library including various letter value substituting systems from ancient times to modern artificial ones.

Currently supported scripts are: greek (ancient), hebrew and english. Planned is a support for arabic, coptic, sanskrit and ethiopian scripts. Some of the systems have been referred with certain name and methodology in the past, these include:

  1. greek -> isopsephy
  2. hebrew -> gematria
  3. arabig -> abjad
  4. sanskrit -> katapayadi

But since not all languages have specific name for this literary device and because of purely recreational purposes I decided to put all systems under same generic library.

Many languages have acrophonic (not alphabetic) numerals also. Most well known perhaps are roman numbers: I, V, X, L, C, D, M. Greeks had Attic (also called Herodianic) numerals, but any of these should not be confuced with alphabetic numerals implemented on Abnum library.

Usage

Import Abnum class and scripts from the abnum package:


In [1]:
from abnum import Abnum, greek, hebrew, english

Initialize abnum object which holds all main functionality for alphabet numeral value calculation:


In [2]:
g = Abnum(greek)
phrase = 'ο Λογος'
print phrase, (g.convert(phrase), g.value(phrase))


ο Λογος ('o Logos', 443)

Thus we can see that ο Λογος (the Word, philosophical/theological concept) is transliterated to 'o Logos' and its alphabetic numeral value (or isopsephic value in this case of greek example) is 443.

Abnum uses romanize transliteration module for converting a script to roman letters. But is also works other way around. You can get a greek script presentation of the word as well:


In [3]:
print g.convert('o Logos')


ο Λογοσ

Some of the scripts have capital letters and some doesn't. This is affected on the functioning in a way that for example in greek and english small and capital letters have same value and their form is reserved on conversion.


In [4]:
print g.convert('GAIOS IOYLIOS KAISAR'), ',', \
      g.convert('GAIOS IOYLIOS KAISAR'.title())


ΓΑΙΟΣ ΙΟΨΛΙΟΣ ΚΑΙΣΑΡ , Γαιοσ Ιοψλιοσ Καισαρ

But scripts like hebrew doesn't have separate small or capital letters. Transliteration module in this case have special meaning on capital letters and their numerical value is not same with small letters. Capital "M" has a value 600 and small "m" 40 in hebrew gematria. Big letter are used as final letters as described by ancient "Mispar gadol" method of gematria. See the difference of spelling and value for the Hebrew word God:


In [5]:
h = Abnum(hebrew)
print h.value('alhiM'), h.convert('alhiM')
print h.value('alhim'), h.convert('alhim')


649 אלחים
89 אלחימ

Value conversion is made by default mapping, but in some cases (either because of using different letter value mapping from the various traditions or artificial one for tests) you may want to provide your own mapping. Take for example default english data mapping provided (Marty Leeds) which is:


In [6]:
e1 = Abnum(english)
print e1.data


([1, 'a'], [2, 'b'], [3, 'c'], [4, 'd'], [5, 'e'], [6, 'f'], [7, 'g'], [6, 'h'], [5, 'i'], [4, 'j'], [3, 'k'], [2, 'l'], [1, 'm'], [1, 'n'], [2, 'o'], [3, 'p'], [4, 'q'], [5, 'r'], [6, 's'], [7, 't'], [6, 'u'], [5, 'v'], [4, 'w'], [3, 'x'], [2, 'y'], [1, 'z'])

But in english script, there are several different mappings, which you could use instead. So let's see one example:


In [7]:
word = "the key"
print "Using a default english mapping and getting a value for the word: '%s' = %s" % (word, e1.value(word))
# defining custom mapping, simple english gematria
mapping = ([1,  'a'], [2,  'b'], [3,  'c'], [4,  'd'], [5,  'e'], [6,  'f'], [7,  'g'], [8,  'h'], [9, 'i'], 
           [10, 'j'], [11, 'k'], [12, 'l'], [13, 'm'], [14, 'n'], [15, 'o'], [16, 'p'], [17, 'q'], [18, 'r'], 
           [19, 's'], [20, 't'], [21, 'u'], [22, 'v'], [23, 'w'], [24, 'x'], [25, 'y'], [26, 'z'])
e2 = Abnum(english, mapping) # must exclude all other letters to prevent exception...
print "Using a custom  english mapping and getting a value for the word: '%s' = %s" % (word, e2.value(word))


Using a default english mapping and getting a value for the word: 'the key' = 28
Using a custom  english mapping and getting a value for the word: 'the key' = 74

Other useful feature from romanize module is implemented by preprocess functionality, when special accent letters are converted to corresponding normal letters. This is because in alphabetic numerals conversion accents don't carry any special meaning. You can use prerocessing via second parameter in convert method.


In [8]:
print g.convert('ἀδελφέ, βοήθει', True)


adelfe boêhei

Now phrase is ready for value calculation. Note that use can use transliteration version of the string for calculation as well.


In [9]:
print g.value(g.convert('ἀδελφέ, βοήθει', True)), '=', g.value('adelfe boêhei')


649 = 649

Two other methods for analyzing value of the phrases are: char_table and char_table_data. See examples below:


In [10]:
g.char_table('ο Λογος')


Out[10]:
ο Λογος
ο  Λογος
70 7373 4
443 11 / 2
oLogos
703070370200

In [11]:
a, b, c = g.char_table_data('ο Λογος')

In [12]:
a


Out[12]:
letter transliteration value word
0 ο o 70 ο
1 Λ L 30 Λογος
2 ο o 70 Λογος
3 γ g 3 Λογος
4 ο o 70 Λογος
5 ς s 200 Λογος

In [13]:
b


Out[13]:
value characters digital_sum digital_root
word
Λογος 373 5 13 4
ο 70 1 7 7

In [14]:
c


Out[14]:
characters digital_root digital_sum phrase value
0 6 2 11 ο Λογος 443

And last but not the least Abnum package supports finding number patterns from phrases with find -method. This is useful for examining possible word and phrase patterns on bigger text corpuses. And this is actually the reason why library was made in first hand. As a real historical example I will use a poem created by first and second century isopsephist, probably the father of Claudius Galen, architect Niko, who was said to have mastered this art to its extremes.

"Helios, you allow the light to assume its spiral shape with your
swith horses, thus you have sent every day your rays to men having
completed everything, since you established the route of Sun and
(then) the never ending Earth, the outpuring Water, Air and Fire,
everything proceeds ordinally.
"

Let's Abnum library calculate the value of the each line (in greek) and then find number patterns that were in the mind of original authors. Original artifact available in the Museum of Pergamum has second part of the poem broken, but first part is fully reconstructed here:


In [15]:
ss = ["ΑΙΛΙΟΥ ΝΕΙΚΩΝΟΣ ・ ẠΨΚϚ ・ ΑΡΧΙΤΕΚΤΟΝΟΣ",
      "ΗΛΙΕ ΘΟΑΙΣ ΙΠΠΟΙΣΙΝ ΕΙΛΙΣΣΩΝ ΦΛΟΓΑ",
      "ΩΣ ΠΑΝΤΕΛΗ ΘΝΗΤΟΙΣΙ ΤΗ ΤΟΤΕ Γ ΗΜΕΡΑ",
      "ΑΚΤΕΙΝΑΣ ΕΦΗΚΑΣ ΘΕΜΕΝΟΣ ΗΛΙΟΥ ΔΡΟΜΟΥΣ",
      "ΚΑΙ ΤΗΝ ΑΠΕΙΡΟΝ ΓΑΙΑΝ ΗΔΕ ΥΓΡΟΥ ΧΥΣΕΙΣ",
      "ΑΕΡΑ ΤΕ ΚΑΙ ΠΥΡ ΕΝ ΤΑΞΕΙ ΦΟΡΟΥΜΕΝΑ",
      "ṂĖ"]

for s in ss:
    print g.value(g.preprocess(s)), s

s = g.preprocess(' '.join(ss))

print "Total value: %s" % g.value(s)

v1 = 1726
v2 = 15000

print ""
print "Find phrases with a value %s and %s:" % (v1, v2)
print ""
for x in g.find(s, v1, True):
    print v1, x
print ""
for x in g.find(s, v2, True):
    print v2, x


5178 ΑΙΛΙΟΥ ΝΕΙΚΩΝΟΣ ・ ẠΨΚϚ ・ ΑΡΧΙΤΕΚΤΟΝΟΣ
2762 ΗΛΙΕ ΘΟΑΙΣ ΙΠΠΟΙΣΙΝ ΕΙΛΙΣΣΩΝ ΦΛΟΓΑ
3271 ΩΣ ΠΑΝΤΕΛΗ ΘΝΗΤΟΙΣΙ ΤΗ ΤΟΤΕ Γ ΗΜΕΡΑ
3102 ΑΚΤΕΙΝΑΣ ΕΦΗΚΑΣ ΘΕΜΕΝΟΣ ΗΛΙΟΥ ΔΡΟΜΟΥΣ
3175 ΚΑΙ ΤΗΝ ΑΠΕΙΡΟΝ ΓΑΙΑΝ ΗΔΕ ΥΓΡΟΥ ΧΥΣΕΙΣ
2690 ΑΕΡΑ ΤΕ ΚΑΙ ΠΥΡ ΕΝ ΤΑΞΕΙ ΦΟΡΟΥΜΕΝΑ
15000 ṂĖ
Total value: 35178

Find phrases with a value 1726 and 15000:

1726 ΑΙΛΙΟΥ ΝΕΙΚΩΝΟΣ
1726 ẠΨΚϚ
1726 ΑΡΧΙΤΕΚΤΟΝΟΣ

15000 ΗΛΙΕ ΘΟΑΙΣ ΙΠΠΟΙΣΙΝ ΕΙΛΙΣΣΩΝ ΦΛΟΓΑ ΩΣ ΠΑΝΤΕΛΗ ΘΝΗΤΟΙΣΙ ΤΗ ΤΟΤΕ Γ ΗΜΕΡΑ ΑΚΤΕΙΝΑΣ ΕΦΗΚΑΣ ΘΕΜΕΝΟΣ ΗΛΙΟΥ ΔΡΟΜΟΥΣ ΚΑΙ ΤΗΝ ΑΠΕΙΡΟΝ ΓΑΙΑΝ ΗΔΕ ΥΓΡΟΥ ΧΥΣΕΙΣ ΑΕΡΑ ΤΕ ΚΑΙ ΠΥΡ ΕΝ ΤΑΞΕΙ ΦΟΡΟΥΜΕΝΑ
15000 ṂĖ

In [16]:
#g.char_table(s.decode('utf8').lower().encode('utf8'))
g.char_table(s)


Out[16]:
ΑΙΛΙΟΥ ΝΕΙΚΩΝΟΣ ẠΨΚϚ ΑΡΧΙΤΕΚΤΟΝΟΣ ΗΛΙΕ ΘΟΑΙΣ ΙΠΠΟΙΣΙΝ ΕΙΛΙΣΣΩΝ ΦΛΟΓΑ ΩΣ ΠΑΝΤΕΛΗ ΘΝΗΤΟΙΣΙ ΤΗ ΤΟΤΕ Γ ΗΜΕΡΑ ΑΚΤΕΙΝΑΣ ΕΦΗΚΑΣ ΘΕΜΕΝΟΣ ΗΛΙΟΥ ΔΡΟΜΟΥΣ ΚΑΙ ΤΗΝ ΑΠΕΙΡΟΝ ΓΑΙΑΝ ΗΔΕ ΥΓΡΟΥ ΧΥΣΕΙΣ ΑΕΡΑ ΤΕ ΚΑΙ ΠΥΡ ΕΝ ΤΑΞΕΙ ΦΟΡΟΥΜΕΝΑ ṂĖ
ΑΙΛΙΟΥ  ΝΕΙΚΩΝΟΣ  ΨΚϚ  ΑΡΧΙΤΕΚΤΟΝΟΣ  ΗΛΙΕ  ΘΟΑΙΣ  ΙΠΠΟΙΣΙΝ  ΕΙΛΙΣΣΩΝ  ΦΛΟΓΑ  ΩΣ  ΠΑΝΤΕΛΗ  ΘΝΗΤΟΙΣΙ  ΤΗ  ΤΟΤΕ  Γ  ΗΜΕΡΑ  ΑΚΤΕΙΝΑΣ  ΕΦΗΚΑΣ  ΘΕΜΕΝΟΣ  ΗΛΙΟΥ  ΔΡΟΜΟΥΣ  ΚΑΙ  ΤΗΝ  ΑΠΕΙΡΟΝ  ΓΑΙΑΝ  ΗΔΕ  ΥΓΡΟΥ  ΧΥΣΕΙΣ  ΑΕΡΑ  ΤΕ  ΚΑΙ  ΠΥΡ  ΕΝ  ΤΑΞΕΙ  ΦΟΡΟΥΜΕΝΑ  Ė
521 81205 81726 71726 753 8290 2510 61305 9604 11000 1474 6657 9308 2675 93 3154 1587 2734 5379 1518 5884 231 4358 7316 165 217 8973 11415 2107 8305 831 4580 455 1376 71236 315000 6
35178 24 / 6
AILIOUNEIKÔNOSYKWARXITEKTONOSÊLIEHOAISIPPOISINEILISSÔNFLOGAÔSPANTELÊHNÊTOISITÊTOTEGÊMERAAKTEINASEFÊKASHEMENOSÊLIOUDROMOUSKAITÊNAPEIRONGAIANÊDEUGROUXUSEISAERATEKAIPURENTACEIFOROUMENAĖ
110301070400505102080050702001000700206110060010300520300705070200830105970110200108080701020010505103010200200800505003070318002008015030053089508300701020010300830070300538405100112030051050120055008201200954055070200830107040041007040704002002011030085018051010070503110150845400310070400600400200510200151001300520110804001005503001605105007010070400405501100005000

In [17]:
a, b, c = g.char_table_data(s)
b


Out[17]:
value characters digital_sum digital_root
word
ΑΕΡΑ 107 4 8 8
ΑΙΛΙΟΥ 521 6 8 8
ΑΚΤΕΙΝΑΣ 587 8 20 2
ΑΠΕΙΡΟΝ 316 7 10 1
ΑΡΧΙΤΕΚΤΟΝΟΣ 1726 12 16 7
Γ 3 1 3 3
ΓΑΙΑΝ 65 5 11 2
ΔΡΟΜΟΥΣ 884 7 20 2
ΕΙΛΙΣΣΩΝ 1305 8 9 9
ΕΝ 55 2 10 1
ΕΦΗΚΑΣ 734 6 14 5
ΗΔΕ 17 3 8 8
ΗΛΙΕ 53 4 8 8
ΗΛΙΟΥ 518 5 14 5
ΗΜΕΡΑ 154 5 10 1
ΘΕΜΕΝΟΣ 379 7 19 1
ΘΝΗΤΟΙΣΙ 657 8 18 9
ΘΟΑΙΣ 290 5 11 2
ΙΠΠΟΙΣΙΝ 510 8 6 6
ΚΑΙ 62 6 8 8
ΝΕΙΚΩΝΟΣ 1205 8 8 8
ΠΑΝΤΕΛΗ 474 7 15 6
ΠΥΡ 580 3 13 4
ΤΑΞΕΙ 376 5 16 7
ΤΕ 305 2 8 8
ΤΗ 308 2 11 2
ΤΗΝ 358 3 16 7
ΤΟΤΕ 675 4 18 9
ΥΓΡΟΥ 973 5 19 1
ΦΛΟΓΑ 604 5 10 1
ΦΟΡΟΥΜΕΝΑ 1236 9 12 3
ΧΥΣΕΙΣ 1415 6 11 2
ΩΣ 1000 2 1 1
ṂĖ 15000 2 6 6
ẠΨΚϚ 1726 4 16 7

In [18]:
from IPython.core.display import HTML
with open('abnum.css') as f:
    css = f.read()
HTML('<style>%s</style>' % css)


Out[18]:

The MIT License

Copyright (c) 2015 Marko Manninen